<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>colorpicker.js</title>
	<script src="./colorpicker.js"></script>
	<style>
		html, body {
			width: 100%;
			height: 100%;
			margin: 0;
			padding: 0;
		}
		.container {
			width: 100%;
			height: 100%;
			display: flex;
			align-items: center;
			flex-direction: column;
		}
		.picker {
			width: 300px;
			height: 20px;
			cursor: pointer;
		}
	</style>
</head>
<body>
	<div class="container">
		<h3>点击下方选择颜色</h3>
		<div class="picker" id="color-picker"></div>
	</div>
</body>
<script>
	var obj = document.getElementById("picker");
	var a = Colorpicker.create({
		el: "color-picker",
		color: "#000fff",
		change: function (el, hex, rgb) {
			el.style.backgroundColor = hex;
			// el.style.backgroundColor = `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${rgb.a})`;
			// console.log(el, hex, rgb);
			console.log(hex, rgb);
		}
	})
</script>
</html>